//
//  MYYMeVisitorCell.m
//  meiyinxiang
//
//  Created by 陈李飞 on 2017/10/25.
//  Copyright © 2017年 hbjApple. All rights reserved.
//

#import "MYYMeVisitorCell.h"
#import "MYY_Me_Macro.h"
#import "myfollowListModel.h"


@interface MYYMeVisitorCell()
@property(nonatomic, strong) UIImageView *iconView;
@property(nonatomic, strong) UILabel *nameView;
@property(nonatomic, strong) UIImageView *indicatorView;
@property(nonatomic, strong) UIView *seperatorView;
@property(nonatomic, strong) UILabel *contentLable;
@end
@implementation MYYMeVisitorCell
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"MYYMeVisitorCell";
    MYYMeVisitorCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[MYYMeVisitorCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
        cell.selectionStyle          = UITableViewCellSelectionStyleNone;
        cell.backgroundColor         = [UIColor whiteColor];
    }
    
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initCreatUI];
        
    }
    return self;
}

-(void)initCreatUI
{
    [self addSubview:self.iconView];
    [self addSubview:self.nameView];
    [self addSubview:self.indicatorView];
    [self addSubview:self.seperatorView];
    [self addSubview:self.contentLable];
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(20);
        make.centerY.equalTo(self);
        make.height.equalTo(@40);
        make.width.equalTo(@40);
    }];
    [self.nameView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).with.offset(12);
        make.top.equalTo(self.iconView.mas_top);
    }];
    [self.indicatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).with.offset(-20);
        make.centerY.equalTo(self);
    }];
    [self.contentLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameView);
       // make.right.equalTo(self.indicatorView.mas_left).with.offset(-12);
        make.top.equalTo(self.nameView.mas_bottom).mas_offset(5);
    }];
    
    [self.seperatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView);
        make.bottom.right.equalTo(self);
        make.height.equalTo(@0.5);
    }];
    
    UITapGestureRecognizer *tapScrollView = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(editContentText)];
    [self.iconView addGestureRecognizer:tapScrollView];
}
-(void)editContentText
{
    self.ziliaoGes();
}


#pragma mark - property
- (UIImageView *)iconView
{
    if (_iconView == nil) {
        _iconView = [UIImageView new];
        _iconView.backgroundColor = [UIColor clearColor];
        _iconView.userInteractionEnabled = YES;
        _iconView.clipsToBounds = YES;
        _iconView.layer.cornerRadius = 20;
    }
    return _iconView;
}

- (UILabel *)nameView
{
    if (_nameView == nil) {
        _nameView = [UILabel new];
        _nameView.backgroundColor = [UIColor clearColor];
        _nameView.numberOfLines = 1;
        _nameView.textColor = MYYtitleColor;
        _nameView.font = [UIFont systemFontOfSize:16.0];
      //  _nameView.text = @"收藏";
    }
    return _nameView;
}
- (UILabel *)contentLable
{
    if (_contentLable == nil) {
        _contentLable = [UILabel new];
        _contentLable.backgroundColor = [UIColor clearColor];
        _contentLable.numberOfLines = 1;
        _contentLable.textColor = QFCTielecColor;
        _contentLable.font = MYYFont(12.0);
    }
    return _contentLable;
}
- (UIImageView *)indicatorView
{
    if (_indicatorView == nil) {
        _indicatorView = [[UIImageView alloc] init];
        _indicatorView.backgroundColor = [UIColor clearColor];
    }
    return _indicatorView;
}

- (UIView *)seperatorView
{
    if (_seperatorView == nil) {
        _seperatorView = [UIView new];
        _seperatorView.backgroundColor = [UIColor colorWithRed:238/255.0 green:238/255.0 blue:238/255.0 alpha:1.0];
    }
    return _seperatorView;
}

-(void)setMyfollowListMode:(myfollowListModel *)myfollowListMode{
    _myfollowListMode = myfollowListMode;
    [_iconView sd_setImageWithURL:[NSURL URLWithString:myfollowListMode.image] placeholderImage:[UIImage imageNamed:@"AppIcon"]];
    _nameView.text      = myfollowListMode.nickname;
    if ([myfollowListMode.titile isEqualToString:@"我的关注"]) {
       _contentLable.text      = [NSString stringWithFormat:@"发红包数 %@     粉丝量 %@",myfollowListMode.redpackt,myfollowListMode.fans];
        if ([myfollowListMode.is_follow isEqualToString:@"1"]) {
            _indicatorView.image= [UIImage imageNamed:@"huxiangguanzhu"];
        }else if ([myfollowListMode.is_follow isEqualToString:@"0"]){
            _indicatorView.image= [UIImage imageNamed:@"yiguanzhu"];
        }
    }else{
        _contentLable.text      = [NSString stringWithFormat:@" %@",myfollowListMode.signature];
        if ([myfollowListMode.is_follow isEqualToString:@"1"]) {
            _indicatorView.image= [UIImage imageNamed:@"huxiangguanzhu"];
        }else if ([myfollowListMode.is_follow isEqualToString:@"0"]){
            _indicatorView.image= [UIImage imageNamed:@"guanzhu"];
        }
    }
    
  
   
//    _iconView.clipsToBounds = YES;
//    _iconView.layer.cornerRadius = _iconView.frame.size.width/2;
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
